package com.bawei.base.mvvm

import androidx.lifecycle.ViewModel
import com.bawei.base.http.API
import com.bawei.base.http.RetrofitUtils
import com.google.gson.Gson
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody

open class BaseViewModel :ViewModel(){

    val apiService = RetrofitUtils.getRetrofit().create(API::class.java)

    // mapתRequestBody
    fun maoToBody(map:MutableMap<String,Any>):RequestBody{
        val json = Gson().toJson(map)
        val body = RequestBody.create("application/json;charset=utf-8".toMediaType(), json)
        return body
    }
}